package com.ruoyi.driver.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.driver.domain.TbDriverCredentials;
import com.ruoyi.driver.service.ITbDriverCredentialsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 司机证件Controller
 * 
 * @author ruoyi
 * @date 2025-08-27
 */
@RestController
@RequestMapping("/credentials")
public class TbDriverCredentialsController extends BaseController
{
    @Autowired
    private ITbDriverCredentialsService tbDriverCredentialsService;

    /**
     * 查询司机证件列表
     */
    //@RequiresPermissions("driver:credentials:list")
    @GetMapping("/list")
    public TableDataInfo list(TbDriverCredentials tbDriverCredentials)
    {
        startPage();
        List<TbDriverCredentials> list = tbDriverCredentialsService.selectTbDriverCredentialsList(tbDriverCredentials);
        return getDataTable(list);
    }

    /**
     * 导出司机证件列表
     */
    //@RequiresPermissions("driver:credentials:export")
    @Log(title = "司机证件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbDriverCredentials tbDriverCredentials)
    {
        List<TbDriverCredentials> list = tbDriverCredentialsService.selectTbDriverCredentialsList(tbDriverCredentials);
        ExcelUtil<TbDriverCredentials> util = new ExcelUtil<TbDriverCredentials>(TbDriverCredentials.class);
        util.exportExcel(response, list, "司机证件数据");
    }

    /**
     * 获取司机证件详细信息
     */
    //@RequiresPermissions("driver:credentials:query")
    @GetMapping(value = "/{credentialsId}")
    public AjaxResult getInfo(@PathVariable("credentialsId") Integer credentialsId)
    {
        return success(tbDriverCredentialsService.selectTbDriverCredentialsByCredentialsId(credentialsId));
    }

    /**
     * 新增司机证件
     */
    //@RequiresPermissions("driver:credentials:add")
    @Log(title = "司机证件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbDriverCredentials tbDriverCredentials)
    {
        return toAjax(tbDriverCredentialsService.insertTbDriverCredentials(tbDriverCredentials));
    }

    /**
     * 修改司机证件
     */
    //@RequiresPermissions("driver:credentials:edit")
    @Log(title = "司机证件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbDriverCredentials tbDriverCredentials)
    {
        return toAjax(tbDriverCredentialsService.updateTbDriverCredentials(tbDriverCredentials));
    }

    /**
     * 删除司机证件
     */
    //@RequiresPermissions("driver:credentials:remove")
    @Log(title = "司机证件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{credentialsIds}")
    public AjaxResult remove(@PathVariable Integer[] credentialsIds)
    {
        return toAjax(tbDriverCredentialsService.deleteTbDriverCredentialsByCredentialsIds(credentialsIds));
    }
}
